global code "D:\Dropbox\unequal_gains\QJE revision plan\analysis\clean_code"

**************************
*** Part 1: Data Building 
**************************

* 1.a. Prepare Nielsen data
do "$code/1a_HMS_data_building.do"
* 1.b. Prepare RMS data
do "$code/1b_RMS_data_building.do"

* 1.c. Build identifiers for new/destroyed goods
do "$code/1c_product_turnover_data_building.do"
* 1.d. Build spending shares on new/destroyed goods 
* across product space 
do "$code/1d_new_exit_productspace.do"
* 1.e. Build inflation across product space
do "$code/1e_inflation_productspace_HMS.do"
do "$code/1e_inflation_productspace_RMS.do"

* 1.f/g Prepare CEX data
do "$code/1f_import_CEX_panel.do"
do "$code/1g_import_CEX_hierachy.do"
* 1.h Finalize CEX and CPI datasets and match them to each other
do "$code/1h_CEX_CPI_match.do"

*******************************
*** Part 2: Summary Statistics 
*******************************

* Table 1
do "$code/2_Table1.do"

**************************************************************
*** Part 3: Income-Group-Specific Inflation & Product Variety
**************************************************************

* Figure 1
do "$code/3a_Figure1.do"

* Figure 2
do "$code/3b_Figure2A.do"
do "$code/3c_elasticitiesAll.do"
do "$code/3d_elasticitiesQ1.do"
do "$code/3e_elasticitiesQ5.do"
do "$code/3f_Figure2BC.do"

* Figure 3
do "$code/3g_Figure3.do"

* Tables 2, 3 and 4
do "$code/3h_Table2_HMS.do"
do "$code/3i_Table2_RMS.do"
do "$code/3j_Table3.do"

*******************************************
*** Part 4: Downward-Sloping Supply Curve
*******************************************

* Build product space outcomes & shocks in household/product spaces 
do "$code/4a_outcomes_building.do"
do "$code/4b_initial_spending_shares.do"
do "$code/4c_household_shocks_building.do"
do "$code/4d_product_space_shocks_building.do"

* Figure 4
do "$code/4e_Figure4.do"

* Table 4
do "$code/4f_Table4.do"

* Figure 5 
do "$code/4g_Figure5.do"

* Table 5
do "$code/4h_Table5.do"

* Table 6
do "$code/4i_Table6.do"

* Build state-level product space outcomes & state-level shocks in household/product space
do "$code/4k_inflation_productspace_RMS_state.do"
do "$code/4l_initial_spending_shares_state.do"
do "$code/4m_product_space_shocks_building_state.do"

* Figure 6
do "$code/4n_Figure6.do"

* Table 7
do "$code/4o_Table7.do"

* Build markup data 
do "$code/4p_markup_reducedform.do"
do "$code/4q_markup_structural.do"

* Table 8
do "$code/4r_Table8A.do"
do "$code/4s_Table8B.do"

************************
*** Part 5: Calibration
************************

* Get demand shocks from changes in the income distribution 
do "$code/5a_incomedistr_changes.do"
do "$code/5b_product_space_shocks_building_income.do"

* Build variety-adjusted inflation across QM
do "$code/5c_feenstra_ces_QM.do"

* Figure 7
do "$code/5d_Figure7.do"

* Table 9
do "$code/5e_Table9.do"
